<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/8/14
 * Time: 9:03
 */

namespace app\admin\controller;

use app\common\controller\AdminBase;
use think\Db;
use app\common\model\Red as RedModel;
/**
 * 后台首页
 * Class Index
 * @package app\admin\controller
 */
class Red extends AdminBase
{
    protected  $_red_model;
    protected function _initialize()
    {
        parent::_initialize();
        $this->_red_model= new RedModel();
    }

    /*
     * 男性：(身高cm－80)×70﹪=标准体重 女性：(身高cm－70)×60﹪=标准体重
     * */
    public function index(){

        $red_data = $this->_red_model->order(['create_time' => 'DESC'])->select();
        $red_num = $this->_red_model->count();
        $red_num_boy = $this->_red_model->where('sex',1)->count();
        $red_num_girl =$red_num - $red_num_boy;
        return $this->fetch('index',
            [   'q_num'=>$red_num,
                'q_boy'=>$red_num_boy,
                'q_girl'=>$red_num_girl,
                'reds'=>$red_data]
        );
    }


}